<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  <script>
    var str = 'Hello Word';
    var reg = /(\w+)\s(\w+)/gi;
    var newStr = str.replace(reg, '$1 World');
    console.log(newStr);    // 输出结果：Hello World
  </script>
</body>
</html>